//
// Created by konglinglong on 2020/9/9.
//

#ifndef CSP_INCLUDE_UTILS_LOG_H
#define CSP_INCLUDE_UTILS_LOG_H

#include "../common/commDef.h"
#include "logDef.h"

#ifdef __cplusplus
extern "C"
{
#endif

typedef enum
{
    LOG_LVL_DBG,
    LOG_LVL_INF,
    LOG_LVL_WRN,
    LOG_LVL_ERR,
    LOG_LVL_BUTT,
} E_LogLevel;

int32_t LOG_Init();
int32_t LOG_Final();
void LOG_UpdateTick(uint64_t tick);
void LOG_SetLogLevel(uint32_t lvl);
void LOG_SetAppType(const char *appTypeStr);
void LOG_SetModuleNameTable(const char *moduleName[], uint32_t size, uint32_t prefixLen);

#define CSP_LOG_DBG(md, fmt, ...) CSP_LOG_COMM(md, LOG_LVL_DBG, FALSE, fmt, __VA_ARGS__)
#define CSP_LOG_INF(md, fmt, ...) CSP_LOG_COMM(md, LOG_LVL_INF, FALSE, fmt, __VA_ARGS__)
#define CSP_LOG_WRN(md, fmt, ...) CSP_LOG_COMM(md, LOG_LVL_WRN, FALSE, fmt, __VA_ARGS__)
#define CSP_LOG_ERR(md, fmt, ...) CSP_LOG_COMM(md, LOG_LVL_ERR, FALSE, fmt, __VA_ARGS__)
#define CSP_LOG_SYNC(md, lvl, fmt, ...) CSP_LOG_COMM(md, lvl, TRUE, fmt, __VA_ARGS__)

#define CSP_LOG_MEM(md, lvl, ptr, size) CSP_LOG_MEM_IMPL(md, lvl, ptr, size)

#ifdef __cplusplus
}
#endif

#endif //CSP_INCLUDE_UTILS_LOG_H
